<?php
class Main_Model
{
	/**
	 * @var array
	 */
	protected static $_loadedClasses;
	
	/**
	 * @param string $name
	 * @return Main_Db_Table_Abstract
	 */
	public static function factory($name)
	{
		if (!empty(self::$_loadedClasses[$name])) {
            return self::$_loadedClasses[$name];
        } else {
			$className = Main_Const::APP_NAMESPACE . $name;
			if (! class_exists($className)) {
				throw new Exception("Класс $className не существует");
			} else {
				
				$class = new $className();
				self::$_loadedClasses[$name] = $class;
				$class->init();				
				return $class;  
			}  
        }	
	}


}